package tx.oopa.circuit.io;

import java.io.IOException;

public class FileContext {
    
    private IFileStrategy strategy;
    
    public FileContext(IFileStrategy strategy) {
        this.strategy = strategy;
    }
    
    public Object readFromFile(String path) throws IOException {
        if(!strategy.fileIsValid(path)) {
            throw new IllegalArgumentException("The file which is related to the given path is not valid");
        }
        return strategy.readFromFile(path);
    }
    
    public boolean fileIsValid(String path) throws IOException {
        return strategy.fileIsValid(path);
    }
}
